package cn.com.coldg.action;

import java.util.ArrayList;
import java.util.List;

import cn.com.coldg.bean.UserTeam;
import cn.com.coldg.factory.DAOFactory;

import com.opensymphony.xwork2.ActionSupport;

public class TeamAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private UserTeam team;
	private List <UserTeam> teamList= new ArrayList<UserTeam>();
	private int id;
	
	

	public String findById(){
		team = DAOFactory.getUserTeamDAOInstance().findById(id);
		return SUCCESS;
	}
	public String addTeam()throws Exception{
		try {
			DAOFactory.getUserTeamDAOInstance().add(team);
			
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ERROR;
	}
	
	public String modify(){
			DAOFactory.getUserTeamDAOInstance().update(team);
			return SUCCESS;
	}


	
	public String Query(){
		teamList = DAOFactory.getUserTeamDAOInstance().findAll();
		return SUCCESS;
	}
	
	public String delete(){
		boolean ret = DAOFactory.getUserTeamDAOInstance().delete(id);
		if(ret){
			return SUCCESS;
		}else{
			return ERROR;
		}	
	}
	
	public UserTeam getTeam() {
		return team;
	}
	public void setTeam(UserTeam team) {
		this.team = team;
	}
	public List<UserTeam> getTeamList() {
		return teamList;
	}

	public void setTeamList(List<UserTeam> teamList) {
		this.teamList = teamList;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}

}
